<extend name="Layout/ins_page" />
<block name="content">
	<!-- {:W('PageHeader/simple',array($flow_type['name'].'：'.$vo['name']))} -->
	<div class="operate panel panel-default hidden-print">
		<div class="panel-body">
			<div class="pull-left">
				<a onclick="go_return_url();" class="btn btn-sm btn-primary">返回</a>
				<eq name="is_edit" value="1">
				
				</eq>
				<a href="#flow_status"  class="btn btn-sm btn-primary">审批情况</a>
				
			</div>
			<div class="pull-right">
				<a onclick="winprint();" class="btn btn-sm btn-primary hidden-xs">打印</a>
				<eq name="vo.step" value="40">
					<a onclick="popup_refer();" class="btn btn-sm btn-primary">传阅</a>
				</eq>
				<eq name="save" value="1">
					<a onclick="save();" class="btn btn-sm btn-primary">保存</a>
				</eq>
			</div>
		</div>
	</div>
	<!--审批人可编辑模板  -->
	<eq name="is_edit" value="1">
			<form method='post' id="form_data" name="form_data" enctype="multipart/form-data" class="well form-horizontal">
		
	    <input type="hidden" id="confirm" name="confirm" >
		<input type="hidden" id="confirm_name" name="confirm_name" >

		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">请假类型：</label>			
			<div class="col-sm-10">
				<select class="form-control" id='type' name = 'type' <?php echo $read ?> >
				<?php foreach($typelist as $type){?>
				<option   <?php if($type['key']==$leave['type']){echo "selected='selected'";}?>  value="<?php echo $type['key']?>"><?php echo $type['value']?></option>
				<?php };?>
				</select>
			</div>
		</div>
		
		<div class="form-group col-xs-12">
			<label class="col-sm-2 control-label" for="type">审批步骤：</label>
			<div class="col-sm-10">
				<div id="confirm_wrap" class="inputbox" style="margin-left: -5px">
					<a class="pull-right btn btn-link text-center" onclick="popup_flow();"> <i class="fa fa-user"></i> </a>
					<div class="wrap" >
						<span class="address_list"></span>
						<span class="text" >
							<?php echo $leave['confirm_name']?>
						</span>
					</div>
					<div class="search dropdown ">
						<ul class="dropdown-menu"></ul>
					</div>
				</div>
			</div>
		</div>

			<div class="form-group">
			<label class="col-sm-2 control-label" for="name">请假时间：</label>			
			<div class="col-sm-10">
			<input  <?php echo $read ?> type="text" style='width: 200px;float: left'  id="start_time" name="start_time" readonly="readonly" class="form-control input-date-ymd-h changge-h" check="require" msg="请输入开始日期" value="<?php echo date('Y-m-d H:i:s',$leave['start_time'])?>">
			<span style="float: left;;margin: 10px">至</span>
			<input  <?php echo $read ?> style='width: 200px;float: left' type="text" id="end_time" name="end_time" readonly="readonly" class="form-control input-date-ymd-h changge-h" check="require" msg="请输入结束日期" readonly="readonly"  value="<?php echo date('Y-m-d H:i:s',$leave['start_time'])?>" >					
			</div>
		</div>
		
		
		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">复工时间：</label>			
			<div class="col-sm-10">
			<input   <?php echo $read ?> value="<?php echo date('Y-m-d H:i:s',$leave['comeback_time'])?>" type="text" style='width: 200px;float: left'  id="comeback_time" name=" comeback_time" readonly="readonly" class="form-control input-date-ymd-h" check="require" msg="请输入复工日期">				
			</div>
		</div>
		
			<div class="form-group">
			<label class="col-sm-2 control-label" for="name">总时(小时)：</label>			
			<div class="col-sm-10">
				<input  <?php echo $read ?> class="form-control" type="text" id="count_time_h" name="count_time_h" value="<?php echo $leave['count_time_h'] ?>" >
			</div>
		</div>
		
		<div class="form-group" id='deductions_day_div'>
			<label class="col-sm-2 control-label" for="name">扣除工资(天)：</label>			
			<div class="col-sm-10">
				<input class="form-control"  <?php echo $read ?> type="text" id="deductions_day" name="deductions_day" value="<?php echo $leave['deductions_day'] ?>">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-2 control-label" for="name">请假事由：</label>			
			<div class="col-sm-10">
			<textarea class="content " <?php echo $read ?>  name="content" style="width:100%;height:300px;" ><?php echo $leave['udf_data'] ?></textarea>
			</div>
		</div>
			
		

	</form>
		
	</eq>
	<!--审批人不可编辑模板  -->


	<a id="flow_status"></a>
	{:W('PageHeader/simple',array('name'=>'审批情况','search'=>'N'))}
	<div class="ul_table ul_table_responsive border-bottom">
		<ul>
			<li class="thead">
				<span class="col-6">类型</span>
				<span class="col-9">审批人</span>
				<span class="col-12">日期</span>
				<span class="col-9">结果</span>
				<span class="auto">意见</span>
			</li>
			<volist name="flow_log" id="item">
				<li class="tbody">
					<span class="col-6">{$item.step|show_step_type}</span>
					<span class="col-9">{$item.user_name}</span>
					<span class="col-12">{$item.create_time|to_date='Y-m-d H:i'}</span>
					<span class="col-9">{$item.result|show_result}</span>
					<span class="auto">
						<div style="overflow:hidden">
							{$item.comment}
						</div> </span>
				</li>
			</volist>
		</ul>
	</div>
	
	<notempty name="to_confirm">
		<a id="confirm"></a>
		{:W('PageHeader/simple',array('name'=>'审批意见','search'=>'N'))}
		<form method="post" action="" name="form_confirm" id="form_confirm">
			<input type="hidden" name="id" value="<?php echo $log['id']?>">
			<input type="hidden" name="flow_id" value="<?php echo $leave['id']?>">
			<input type="hidden" name="step" value="<?php echo $leave['step']?>">
			<div class="operate panel panel-default">
				<div class="panel-heading clearfix">
					<div class="pull-left">
						<a onclick="go_return_url();" class="btn btn-sm btn-primary">返回</a>
					</div>
					<div class="pull-right">
						<eq name="is_edit" value="1">
							<div class="btn-group">
								<a class="btn btn-sm btn-warning dropdown-toggle" data-toggle="dropdown" href="#">退回到<span class="fa fa-caret-down"></span> </a>
								<ul class="dropdown-menu col-5">
									<volist name="confirmed" id="vo">
										<li onclick="back_to('{$vo.emp_no}');">
											<a>{$vo.user_name}</a>
										</li>
									</volist>
									<li onclick="back_to('{$emp_no}');">
										<a>{$user_name}</a>
									</li>
								</ul>
							</div>
						
						<a onclick="reject();" class="btn btn-sm btn-danger">否决</a>
						|
						<a onclick="approve();" class="btn btn-sm btn-primary">同意</a>
					</div>
				</div>
				<div class="form-group panel-body">
					<label class="col-sm-2 control-label" >审批意见：</label>
					<div class="col-sm-10">
						<textarea name="comment" class="col-xs-12" style="height:120px"></textarea>
					</div>
				</div>
			</div>
		</form>
	</notempty>
	<notempty name="to_refer">
		{:W('PageHeader/simple',array('name'=>'参阅人意见','search'=>'N'))}
		<form method="post" action="" name="form_confirm" id="form_confirm">
			<input type="hidden" name="id" value="{$to_refer.id}">
			<input type="hidden" name="flow_id" value="{$vo.id}">
			<div class="operate panel panel-default">
				<div class="panel-heading clearfix">
					<div class="pull-left">
						<a onclick="go_return_url();" class="btn btn-sm btn-primary">返回</a>
					</div>
					<div class="pull-right">
						<a onclick="refer();" class="btn btn-sm btn-primary">保存</a>
					</div>
				</div>
				<div class="form-group panel-body">
					<label class="col-sm-2 control-label" >参阅人意见：</label>
					<div class="col-sm-10">
						<textarea name="comment" class="col-xs-12" style="height:120px">{$to_refer.comment}</textarea>
					</div>
				</div>
			</div>
		</form>
	</notempty>
</block>
<block name="js">
	<script type="text/javascript">
		udf_field.init({$vo['udf_data']});
		function approve() {
			sendForm("form_confirm", "{:U('approve')}", "{:U('read','id='.$vo['id'])}");
		}

		function refer() {
			sendForm("form_confirm", "{:U('refer')}", "{:U('read','id='.$vo['id'])}");
		}

		function reject() {
			sendForm("form_confirm", "{:U('reject')}", "{:U('read','id='.$vo['id'])}");
		}

		function back_to(emp_no) {
			sendForm("form_confirm", fix_url("{:U('back_to')}?emp_no=" + emp_no), "{:U('read','id='.$vo['id'])}");
		}

		function save() {
			$("#confirm").val("");
			$("#confirm_wrap  span").each(function() {
				$("#confirm").val($("#confirm").val() + $(this).attr("data") + '|');
			});
			$("#confirm_name").val($("#confirm_wrap").html());

			$("#consult").val("");
			$("#consult_wrap  span").each(function() {
				$("#consult").val($("#consult").val() + $(this).attr("data") + '|');
			});
			$("#consult_name").val($("#consult_wrap").html());

			$("#refer").val("");
			$("#refer_wrap  span").each(function() {
				$("#refer").val($("#refer").val() + $(this).attr("data") + '|');
			});
			$("#refer_name").val($("#refer_wrap").html());

			if ($("#confirm").val().length < 2) {
				ui_error('请选择审批流程');
				return false;
			}
			sendForm("form_data", "{:U('save')}");
		}

		function popup_confirm() {
			winopen("{:U('popup/confirm')}", 560, 470);
		}

		function popup_refer() {
			winopen("{:U('popup/refer')}", 560, 470);
		}

		$(document).ready(function() {
			set_return_url(document.location, 1);
			$('.address_list').on('mouseenter', 'span', function() {
				$i = $(this).find('i');
				$i.removeClass('fa-arrow-right');
				$i.addClass('fa-times');
			});
			$('.address_list').on('mouseleave', 'span', function() {
				$i = $(this).find('i');
				$i.removeClass('fa-times');
				$i.addClass('fa-arrow-right');

				$(".address_list span i:last").attr('class', 'fa');
			});

			$('.address_list').on('click', 'i', function() {
				$(this).parents('span').remove();
			});
			show_content();
		});
	</script>
</block>